package com.wander.methoddemo.Good;

public class GoodsTest {
    public static void main(String[] args) {
        //1.创建一个数组
        Goods [] arr = new Goods[3];

        //2.创建三个商品对象
        Goods g1 = new Goods("01","华为p60",5999.99,100);
        Goods g2 = new Goods("02","被子",99.99,900);
        Goods g3= new Goods("03","枸杞",19.99,70);

        //3.把商品添加懂啊数组中
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;

        //4.遍历
        for (Goods goods : arr) {
            System.out.println(goods.getId() + "，" + goods.getName() + "，" + goods.getPrice() + "，" + goods.getCount());
        }
        /*for (int i = 0; i< arr.length;i++){
            Goods goods = arr[i];
            System.out.println(goods.getId()+"，"+goods.getName()+"，"+goods.getPrice()+"，"+goods.getCount());
        }*/
    }
}
